﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef struct Book_s
{
	double price;
	char name[255];
}Book;

typedef struct TContext_s
{
	int n;
	Book v[20];
}TContext;

TContext context;

void read_data(TContext* ctx)
{
	scanf("%d", &ctx->n);
	for (int i = 0; i < ctx->n; ++i)
	{
		scanf("\n");
		gets(ctx->v[i].name);
		scanf("%lf ", &ctx->v[i].price);
	}
}

void dump_book(Book* book)
{
	printf("%.2f, %s\n", book->price, book->name);
}

void do_task(TContext* ctx)
{
	int i;
	Book* min =& ctx->v[0];
	Book* max = min;
	for (int i = 1; i < ctx->n; ++i)
	{
		if (min->price > ctx->v[i].price)
			min = &ctx->v[i];
		else if (max->price < ctx->v[i].price)
			max = &ctx->v[i];
	}
	dump_book(max);
	dump_book(min);
}

void solve(TContext* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-103.txt", "r", stdin);
	solve(&context);
	return 0;
}
